package com.itcast.yygh.hosp.controller;

import com.itcast.common.result.R;
import com.itcast.yygh.hosp.service.DepartmentService;
import com.itcast.yygh.model.vo.hosp.DepartmentVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 部门数据接口
 */

@Api(tags = "科室数据接口")
@RestController
@RequestMapping("/admin/hosp/department")
@RequiredArgsConstructor
public class DepartmentController {

    private final DepartmentService departmentService;

    //根据医院编号，查询医院所有科室列表
    @ApiOperation(value = "查询医院所有科室列表")
    @GetMapping("getDeptList/{hoscode}")
    public R getDeptList(@PathVariable String hoscode) {
        //调用service中的查询方法
        List<DepartmentVo> list = departmentService.findDeptTree(hoscode);
        return R.ok().data("list",list);
    }

}
